package asteroids.model.programs.expressions.ComposedExpressions.UnaryExpressions;

import asteroids.model.Ship;
import asteroids.model.SpaceObject;
import asteroids.model.programs.expressions.BasicExpression;
import asteroids.model.programs.expressions.BasicExpressions.DoubleLiteral;
import asteroids.model.programs.expressions.Expression;
import asteroids.model.programs.expressions.BasicExpressions.Entity;
import asteroids.model.programs.expressions.ComposedExpressions.UnaryExpression;
import asteroids.model.programs.types.Type;

public class GetDirection extends UnaryExpression {
	/**
	 * 
	 * @param exp
	 * @param line
	 * @param column
	 */
	public GetDirection(Expression exp, int line, int column) {
		super(exp, line, column);
		// TODO Auto-generated constructor stub
	}

	@Override
	public String getOperatorSymbol() {
		return "getDirection";
	}

	@Override
	public BasicExpression getResult() {
		SpaceObject ship = ((Entity)getOperand().getResult()).getValue();
		BasicExpression direction = new DoubleLiteral(((Ship)ship).getDirection(), getLine(), getColumn());
		return direction;
	}
	
	@Override
	public Type getType(){
		return Type.DOUBLE;
	}
	
	@Override
	public Type[] getOperandType(){
		return new Type[]{Type.ENTITY};
	}

}
